//@author A0086393U
package rightnow.ui;

import java.util.Observable;
import java.util.Observer;

import javafx.scene.control.TextField;
import rightnow.logic.FeedbackProvider;

/**
 * This class is a mock main controller used in the FeedbackProviderTest,
 * so FXML is not required to be called.
 *
 */
public class MockMainController implements Observer {

	private TextField cmdLine;
	
	public MockMainController() {
		cmdLine = new TextField();
		
		clearCmdLine();
		
		FeedbackProvider.getInstance().addObserver(this);
	}
	
	private void clearCmdLine() {
		cmdLine.clear();
	}

	@Override
	public void update(Observable o, Object arg) {
		if (o == FeedbackProvider.getInstance()) {
			FeedbackProvider fp = FeedbackProvider.getInstance();
			if (fp.hasCmdLineChanged()) {
				cmdLine.setText(fp.getCmdLine());
			}
		}
	}
	
	// For retrieving test info
	public String getCmdLineText() {
		return cmdLine.getText();
	}
}
